<?php use_helper('PA_Links') ?>
<table id="categoriesTable" style="display: inline-table">
  <th>Nazwa</th>
  <th>Rodzic</th>
  <th>Jednostka</th>
  <th>Parametry</th>
  <th>Zablokowana</th>
  <th>Ilość pozycji</th>
  <th>Edycja</th>
  <?php if(isset($categories)): ?>
  <?php foreach($categories as $category): ?>
  <tr>
    <td style="text-align: left;">
      <?php for($i = 0; $i < $category->getLevel(); $i++): ?>
        <span style="border-left:1px dashed #303030; margin-right: 10px;"></span>
      <?php endfor; ?>
      <span style="<?php if($category->getLevel()): ?>border-left: 2px solid #303030; padding-left: 4px;<?php endif;?>"><?php echo $category->getName() ?>
      </span>
    </td>
    <td><?php echo ($category->getParentCategoryName() === null) ? 'root': $category->getParentCategoryName() ?></td>
    <td><?php echo $category->getQuantityUnit() ? $category->getQuantityUnit() : '-' ?></td>
    <td><?php // OFF (PERFORMANCE) echo ESC_RAW($category->getCategoryParamsString()) ?>-</td>
    <td><?php echo $category->getLocked()? 'Tak' : 'Nie' ?></td>
    <td><?php echo $category->getChildItemsCount(null, false) ?></td>
    <td nowrap="nowrap">
      <img src="/images/icons/change.png" class="middle" width="18" height="18"/>  <a onclick="App.Table.attachForm(this, '<?php echo link_to_app('Core', 'homeGetForm', array('form' => 'CategoryForm', 'form_action' => 'update', 'id' => $category->getId())) ?>', '#categoriesTable', 'updateCategory', 5, 5, true)" class="middle">Zmień</a>
      <img src="/images/icons/delete.png" class="middle" width="18" height="18"/>  <a onclick="return confirm('Jesteś pewien?\nUsuniesz wszystkie kategorie podrzędne i elementy.')" href="<?php echo link_to_app('Store', 'deleteCategory', array('id' => $category->getId())) ?>" class="middle">Usuń</a>
    </td>
  </tr>
  <?php endforeach; ?>
  <?php endif; ?>
  <tr id="add">
    <td colspan="7"><img src="/images/icons/add.png" class="middle" width="18" height="18"/>  <a onclick="App.Table.attachForm(this, '<?php echo link_to_app('Core', 'homeGetForm', array('form' => 'CategoryForm', 'form_action' => 'create')) ?>', '#categoriesTable', 'createCategory', 5, 5)" class="middle">Dodaj</a></td>
  </tr>
</table>